local sk__qinqing = fk.CreateSkill {

  name = "sk__qinqing",

  tags = {  },

}



sk__qinqing:addEffect(fk.EventPhaseStart, {
  name = "sk__qinqing",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__qinqing.name) and player.phase == Player.Finish
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, 1,
      "#sk__qinqing-choose", sk__qinqing.name, true)
    if #to > 0 then
      event:setCostData(self, to[1])
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(event:getCostData(self))
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if to.dead then return end
      if not p.dead and p:inMyAttackRange(to) and not p:isNude() then
        local card = room:askForCard(p, 1, 1, true, sk__qinqing.name, false, ".", "#sk__qinqing-give::"..to.id)
        room:moveCardTo(card, Card.PlayerHand, to, fk.ReasonGive, sk__qinqing.name, nil, false, p)
      end
    end
    if not player.dead and not to.dead and player:getHandcardNum() >= to:getHandcardNum() and to:isWounded()
      and room:askForSkillInvoke(player, sk__qinqing.name, nil, "#sk__qinqing-recover::"..to.id) then
      room:recover({
        who = to,
        num = 1,
        recoverBy = player,
        skillName = sk__qinqing.name
      })
    end
  end,
})

return sk__qinqing